<h1><?php echo $this->Html->image('bootstrap/posts.png')?>订单详情</h1>
<div class="bloc">
	<div class="title">
		<?php echo $this->element('admin/bread')?>
	</div>
    <div class="content">
    	<table width = '80%'>
    		<tr>
    			<th width='20%'>ID</th><td width='30%'><?php echo h($userOrder['UserOrder']['id']); ?></td>
    			<th width='20%'>订单编号</th><td width='30%'><?php echo $userOrder['UserOrder']['ordernum']?></td>
    		</tr>
    		<tr>
    			<th>订单站点</th><td><?php echo $userOrder['SysWebsite']['title']?></td>
    			<th>订单状态</th><td style = 'color:red'>
    				<?php 
    					echo $this->Form->create('UserOrder',array('url'=>array('controller'=>'UserOrders','action'=>'state',$userOrder['UserOrder']['id'])));
    					echo $this->Form->input('id',array('type'=>'hidden','value'=>$userOrder['UserOrder']['id']));
    					echo $this->Form->input('user_order_state_id',array('label'=>false,'div'=>false,'option'=>$userOrderStates,'default'=>$userOrder['UserOrderState']['id']));
    					echo $this->Form->submit('修改',array('label'=>false,'div'=>false));
    					echo $this->Form->end();
    				?>
    			</td>
    		</tr>
    		<tr>
    			<th>支付类型</th><td><?php echo $userOrder['SysPaytype']['title']?></td>
    			<th>支付方式</th><td><?php echo $userOrder['UserOrderPaytype']['title']?>(<?php echo $userOrder['UserOrder']['trade_no']?>)</td>
    		</tr>
    		<tr>
    			<th>配送方式</th><td><?php echo $userOrder['SysGettype']['title']?></td>
    			<th>快递单号</th><td style = 'color:blue'><?php echo $userOrder['UserOrder']['logisticnum']?></td>
    		</tr>
    		<tr>
    			<th>物流费用</th><td style = 'color:green'><?php echo h($userOrder['UserOrder']['price_logistic']); ?></td>
    			<th>订单金额</th><td style = 'color:green'><?php echo h($userOrder['UserOrder']['price_order']); ?></td>
    		</tr>
    		<tr>
    			<th>积分</th><td style = 'color:green'><?php echo h($userOrder['UserOrder']['use_credit']); ?></td>
    			<th>订单总额</th><td style = 'color:green'><?php echo h($userOrder['UserOrder']['price_total']); ?></td>
    		</tr>
    		<tr>
    			<th>发票抬头</th><td style = 'color:blue'><?php echo h($userOrder['UserOrder']['title']); ?></td>
    			<th>备注</th><td style = 'color:blue'><?php echo h($userOrder['UserOrder']['remark']); ?></td>
    		</tr>
    	</table>
	</div>
</div>

<?php if($userOrder['UserOrderState']['id'] == 2):?>
<div class="bloc">
	<div class="title">
		快递单号
	</div>
    <div class="content">
    	<?php echo $this->Form->create('UserOrder',array('url'=>array('controller'=>'UserOrders','action'=>'logistic',$userOrder['UserOrder']['id'])))?>
    	<table width = '80%'>
    		<tr>
    			<th width='20%'>订单号</th>
    			<td width='30%'>
    				<?php 
    					echo $this->Form->input('id',array('type'=>'hidden','value'=>$userOrder['UserOrder']['id']));
    					echo $this->Form->input('logisticnum',array('div'=>false,'label'=>false)); 
    				?>
    			</td>
    			<td width='30%'>
    				<?php echo $this->Form->submit('提交') ?>
    			</td>
    		</tr>
    	</table>
    	<?php echo $this->Form->end()?>
    </div>
</div>
<?php endif;?>

<div class="bloc">
	<div class="title">
		管理员备注
	</div>
    <div class="content">
    	<?php echo $this->Form->create('UserOrder',array('url'=>array('controller'=>'UserOrders','action'=>'edit',$userOrder['UserOrder']['id'])))?>
    	<table width = '90%'>
    		<tr>
    			<td>
    				<?php 
    					echo $this->Form->input('id',array('type'=>'hidden','value'=>$userOrder['UserOrder']['id']));
    					echo $this->Form->input('admin_remark',array('div'=>false,'label'=>false,'style'=>'width:100%;height:40px','default'=>$userOrder['UserOrder']['admin_remark'])); 
    				?>
    			</td>
    		</tr>
    		<tr>
    			<td>
    				<?php echo $this->Form->submit('提交') ?>
    			</td>
    		</tr>
    	</table>
    	<?php echo $this->Form->end()?>
    </div>
</div>


<div class="bloc">
	<div class="title">
		订单明细
	</div>
    <div class="content">
    	<table width = '100%'>
    		<tr>
    			<th width='5%'>ID</th>
    			<th width='25%'>票品</th>
    			<th width='10%'>演出时间</th>
    			<th width='10%'>单价</th>
    			<th width='5%'>数量</th>
    			<th width='5%'>总价</th>
    			<th width='10%'>电子票状态</th>
    			<th width='10%'>操作</th>
    		</tr>
    	<?php foreach($userOrder['UserOrderList'] as $uol):?>
    		<tr>
    			<td>
 					<?php echo $uol['id']?>   			
    			</td>
    			<td>
 					<?php echo $uol['Ticket']['title']?>   			
    			</td>
    			<td>
 					<?php echo $uol['showtime']?>   			
    			</td>
    			<td>
 					<?php echo $uol['price_sigle']?>  
 					<?php if($uol['seat']):?> 			
 					[<?php echo $uol['seat']?>]
 					<?php endif;?>
    			</td>
    			<td>
 					<?php echo $uol['price_num']?>   			
    			</td>
    			<td>
 					<?php echo $uol['price_total']?>   			
    			</td>
    			<td>
 					<?php if($uol['spt_eticket']==1 && $uol['state']==1):?>  			
 						未生成电子票
 					<?php elseif($uol['spt_eticket']==1 && $uol['state']==2):?>
 						已生成电子票
 					<?php elseif($uol['spt_eticket']==1 && $uol['state']==3):?>
 						用户已兑换
 					<?php else:?>
 						不支持
 					<?php endif;?>
    			</td>
    			<td>
 					<?php if($uol['spt_eticket']==1 && $uol['state']==1):?> 
 						<?php if($userOrder['UserOrderState']['id'] >= 2):?> 			
 						<?php echo $this->Html->link('生成电子票',array('controller'=>'UserOrders','action'=>'pubeticket',$uol['id'],$userOrder['UserOrder']['id']))?>
 						<?php else:?>
 						等待订单支付
 						<?php endif;?>
 					<?php elseif($uol['spt_eticket']==1):?>
 						<a href = 'javascript:;' class = 'showeticket'>查看电子票</a>
 						<?php echo $this->Html->image(getETicket($uol['id']),array('style'=>'display:none'))?>
 					<?php else:?>
 						-
 					<?php endif;?>
    			</td>
    		</tr>
    	<?php endforeach;?>
    	</table>
    </div>
</div>
<div class="bloc">
	<div class="title">
		收货人信息
	</div>
    <div class="content">
    	<table width = '100%'>
    		<tr>
    			<th width='20%' height = '25'>收货人</th>
    			<th width='20%'>收货电话</th>
    			<th width='60%'>收货地址</th>
    		</tr>
    		<tr>
    			<td><?php echo $userOrder['UserOrder']['address_receive']?></td>
    			<td><?php echo $userOrder['UserOrder']['address_phone']?></td>
    			<td><?php echo $userOrder['UserOrder']['address']?></td>
    		</tr>
    	</table>
    </div>
</div>
<style>
.bloc th {height:25px; font-weight:bold}
</style>
<script>
$(function(){
	$('.showeticket').toggle(function(){
		$(this).next().slideDown();
	},function(){
		$(this).next().slideUp();
	})
});
</script>